var url = urls();
var params = oneValues();
var page = 1;
if (params.page != undefined) {
    page = parseInt(params.page);
}
function anli_list() {
    $.ajax({
        type: "post",
        url: url + "/api/case/case_list",
        data: {
            page: page,
            number: 5,
        },
        dataType: "json",
        success: function (res) {
            anli_details(res);
        }
    });
}
//案例详情
function anli_details(res) {
    var pageNum = Math.ceil(res.data.total / 5);
    var arr = res.data.data;
    var a = '';
    for (i in arr) {
        a += '<div class="anli_list" id="anli_' + arr[i].id + '"><img src="' + url + '/upload/' + arr[i].thumbnail + '" class="list_img" /><div class="list_right_box"><div class="list_txt_box"><p class="list_title">' + arr[i].post_title + '</p><p class="list_txt">' + arr[i].post_excerpt + '</p></div><p class="list_details">查看详情&nbsp;&gt;</p></div></div>'
    }
    $(".anli_center").html(a);
    excerpt();
    //详情
    $(".anli_list").click(function () {
        window.location.href = url + "/portal/index/anlidetails.html?id=" + this.id;
    })

    $("#page").paging({
        nowPage: page, // 当前页码
        pageNum: pageNum, // 总页码
        buttonNum: 7, //要展示的页码数量
        callback: function (num) { //回调函数
            $(".page_bg").css("display", "block");
            window.location.href = url + "/portal/index/anli.html?page=" + num;
        }
    });
}

function excerpt() {
    for (var i = 0; i < $(".list_txt").length; i++) {
        $(".list_txt").eq(i).html($(".list_txt").eq(i).html().substr(0, 95) + "...");
    }
}

$(function () {
    //首次调用
    anli_list();
})